#许克的作业
import os
import filecmp

def compare_files(folder_path):
    # 获取所有子文件夹
    subfolders = [f.path for f in os.scandir(folder_path) if f.is_dir()]

    # 比较子文件夹中的文件
    for i in range(len(subfolders)):
        for j in range(i + 1, len(subfolders)):
            folder1 = subfolders[i]
            folder2 = subfolders[j]
            for file1 in os.listdir(folder1):
                for file2 in os.listdir(folder2):
                    if file1 == file2 and filecmp.cmp(os.path.join(folder1, file1), os.path.join(folder2, file2), shallow=False):
                        print(f"相同内容的文件: {os.path.join(os.path.basename(folder1), file1)} 和 {os.path.join(os.path.basename(folder2), file2)}")

if __name__ == "__main__":
    desktop_path = os.path.join(os.path.expanduser("~"), "Desktop")
    nnmm_folder = os.path.join(desktop_path, "nnmm")
    compare_files(nnmm_folder)
